using System;

namespace SilverAmp.Common.DecoupledEvents
{
    /// <summary>
    /// Generic implementation of the DecoupledEventBase class.
    /// </summary>
    /// <typeparam name="TPayload">The type of the payload.</typeparam>
    public class DecoupledEvent<TPayload> : DecoupledEventBase
    {
        public SubscriptionToken Subscribe(Action<TPayload> action)
        {
            IDecoupledEventSubscription subscription = new DecoupledEventSubscription<TPayload>(action);
            return base.InternalSubscribe(subscription);
        }

        public virtual void Publish(TPayload payload)
        {
            base.InternalPublish(payload);
        }       
    }
}